import com.usoft.grpc.example.helloworld.GreeterGrpc;
import com.usoft.grpc.example.helloworld.HelloRequest;
import com.usoft.grpc.example.helloworld.HelloResponse;
import io.grpc.stub.StreamObserver;

/**
 * Created by xinxingegeya on 16/1/2.
 */
public class HelloWorldServiceImpl implements GreeterGrpc.Greeter {
    @Override
    public void sayHello(HelloRequest request,
            StreamObserver<HelloResponse> responseObserver) {

        System.out.println("greeter name=" + request.getName());

        HelloResponse response = HelloResponse.newBuilder()
            .setMessage("hello world,greeter").build();

        responseObserver.onNext(response);
        //We use the response observer's onCompleted() method to specify that we've finished dealing with the RPC.
        responseObserver.onCompleted();
    }
}
